package ACEbrickBreaker;

/**
 * <p>Title: TextPanel</p>
 * <p>Description: TextPanel
 *       This panel sets up the text for the game including the score, timer, player name and number of lives</p>
 * @author Caitlin Finn
 * @email caitlin.finn@my.uwrf.edu
 * @author Erin McNeil
 * @email erin.mcneil@my.uwrf.edu
 * @author Andrew Juranek
 * @email andrew.juranek@my.uwrf.edu
 * @date December 10th 2012
 */

import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class TextPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// declares text fields
	private final JTextField time, score, lives, player;
	private final String PlayerName;
	// declare labels for text fields
	private final JLabel timeLabel, scoreLabel, livesLabel, playerLabel;

	/**
	 * default constructor for textfield panel
	 */
	public TextPanel() {
		// ask for player name
		PlayerName = JOptionPane.showInputDialog(null, "Player Name: ",
				"Enter Player Information", JOptionPane.OK_CANCEL_OPTION);

		// creates text field for displaying time
		time = new JTextField(8);
		time.setEditable(false);
		time.setFont(new Font("Arial", Font.BOLD, 20));
		time.setText("00:00");
		time.setBackground(Color.YELLOW);
		time.setHorizontalAlignment(JTextField.CENTER);

		// creates text field for displaying score
		score = new JTextField(8);
		score.setEditable(false);
		score.setFont(new Font("Arial", Font.BOLD, 20));
		score.setText("0");
		score.setBackground(Color.YELLOW);
		score.setHorizontalAlignment(JTextField.CENTER);

		// creates text field for displaying number of lives
		lives = new JTextField(8);
		lives.setEditable(false);
		lives.setFont(new Font("Arial", Font.BOLD, 20));
		lives.setText("3");
		lives.setBackground(Color.YELLOW);
		lives.setHorizontalAlignment(JTextField.CENTER);

		// creates test field for player name
		player = new JTextField(8);
		player.setEditable(false);
		player.setFont(new Font("Arial", Font.BOLD, 12));

		player.setText(PlayerName);
		player.setForeground(Color.WHITE);
		player.setBackground(Color.DARK_GRAY);
		player.setHorizontalAlignment(JTextField.CENTER);
		System.out.println(PlayerName);

		// sets up different panels for each variable
		JPanel timePanel = new JPanel();
		timeLabel = new JLabel();
		timeLabel.setForeground(Color.WHITE);
		timeLabel.setText("Time: ");
		timePanel.add(timeLabel);
		timePanel.add(time);
		timePanel.setBackground(Color.DARK_GRAY);

		JPanel scorePanel = new JPanel();
		scoreLabel = new JLabel();
		scoreLabel.setForeground(Color.WHITE);
		scoreLabel.setText("Score: ");
		scorePanel.add(scoreLabel);
		scorePanel.add(score);
		scorePanel.setBackground(Color.DARK_GRAY);

		JPanel livesPanel = new JPanel();
		livesLabel = new JLabel();
		livesLabel.setForeground(Color.WHITE);
		livesLabel.setText("Lives: ");
		livesPanel.add(livesLabel);
		livesPanel.add(lives);
		livesPanel.setBackground(Color.DARK_GRAY);

		JPanel playerPanel = new JPanel();
		playerLabel = new JLabel();
		playerLabel.setForeground(Color.WHITE);
		playerLabel.setText("Player: ");
		playerPanel.add(playerLabel);
		playerPanel.add(player);
		playerPanel.setBackground(Color.DARK_GRAY);

		// sets up panel in a grid layout of previously created panels
		this.setLayout(new GridLayout(4, 1));
		this.add(timePanel);
		this.add(scorePanel);
		this.add(livesPanel);
		this.add(playerPanel);

	}

	/**
	 * gets the number of lives left from text field
	 * 
	 * @return lives
	 */
	public JTextField getLives() {
		return lives;
	}

	/**
	 * sets the lives text field
	 * 
	 * @param lives
	 */
	public void setLives(String lives) {
		this.lives.setText(lives);
	}

	/**
	 * gets current score from text field
	 * 
	 * @return score
	 */
	public JTextField getScore() {
		return score;
	}

	/**
	 * sets the score text field
	 * 
	 * @param score
	 */
	public void setScore(String score) {
		this.score.setText(score);
	}

	/**
	 * gets the time from text field
	 * 
	 * @return time
	 */
	public JTextField getTime() {
		return time;
	}

	/**
	 * sets the time text field
	 * 
	 * @param time
	 */
	public void setTime(String time) {
		this.time.setText(time);
	}

	/**
	 * gets the PlayerName entered by the player
	 * 
	 * @return PlayerName
	 */
	public String getPlayerName() {
		return PlayerName;
	}

	/**
	 * sets the playerName
	 * 
	 * @param playerName
	 */
	public void setPlayerName(String playerName) {
		this.player.setText(playerName);
	}

}
